{% extends 'base.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% block page_content %}
    {% block makcoo %}
        <div class="panel panel-info">
            <div class="panel-heading">员工列表
                <button onclick="javascript:history.back()" class="btn btn-xs btn-info pull-right" aria-haspopup="true"
                        aria-expanded="false">
                    <i class="fa fa-undo fa-fw"></i>返回
                </button>
                <a href="{{ url_for('employee.employee_add') }}" class="btn btn-xs btn-danger pull-right">
                    <i class="fa fa-plus fa-fw"></i>添加员工
                </a>
            </div>
            <div class="panel-body">

                <form  class="form form-horizontal form-group-sm col-xs-12" method="post"
                      role="form" action="{{ url_for('employee.employee_list') }}">
                    {{ form.hidden_tag() }}
                    <div class="form-group col-xs-4">
                        <div class="row">
                            {{ wtf.form_field(form.keyword, form_type='horizontal', extra_classes="form-group-sm", horizontal_columns=('xs', 4, 8)) }}
                            {{ form.submit(class="btn ") }}
                        </div>
                    </div>
                </form>
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>员工姓名</th>
                        <th>角色</th>
                        <th>企业邮箱</th>
                        <th>联系电话</th>
                        <th>是否在职</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        {% for employee in employees %}
                        <tr>
                            <td>{{ employee.name }}</td>
                            <td>{{ employee.role.name }}</td>
                            <td>{{ employee.email }}</td>
                            <td>{{ employee.phone }}</td>
                            <td>{{  '离职' if employee.is_locked  else '在职' }}</td>
                            <td>
                                <a class="btn btn-xs btn-success" href="/admin/employee/edit/{{ employee.id }}">
                                    <i class="fa fa-edit fa-fw"></i>
                                    编辑
                                </a>
                                <a onclick="return confirm('确定删掉此员工(此操作不可逆)吗?')" class="btn btn-xs btn-danger" href="/admin/employee/delete/{{ employee.id }}">
                                    <i class="fa fa-trash-o fa-fw"></i>删除
                                </a>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>

                </table>

            </div>
        </div>
    {% endblock %}
{% endblock %}